/*
从后台获取一小时前，一天前，。。。的水信息入库数量
*/
var chart1;
var chart2;
var chart3;
var chart4;

var handleProfileSkillPie = function () {
    $('#easypiechart-blue').easyPieChart({});
    chart1 = window.chart = $('#easypiechart-blue').data('easyPieChart');
    $('#asypiechart-orange').easyPieChart({});
    chart2 = window.chart = $('#easypiechart-orange').data('easyPieChart');
    $('#easypiechart-teal').easyPieChart({});
    chart3 = window.chart = $('#easypiechart-teal').data('easyPieChart');
    $('#easypiechart-red').easyPieChart({});
    chart4 = window.chart = $('#easypiechart-red').data('easyPieChart');
}

// var get_water_data = function() {
//     $.ajax({
//         type: 'get',
//         url: '/entity_water/query_index_data',
//         success: function(data) {
//             //console.log(data);
//             // document.getElementById("water_one_hour_before").innerHTML = "" + data.hour;
//             // document.getElementById("water_week").innerHTML = "" + data.week;
//             // document.getElementById("water_day").innerHTML = "" + data.day;
//             // document.getElementById("water_month").innerHTML = "" + data.month;
//         }
//     })
// }


/*
获取各个时间段预警比例
*/
var get_warning_record = function() {
    $.ajax({
        type: 'get',
        url: '/warning_record/query_index_data',
        success: function(data) {
            $("#easypiechart-blue").attr('data-percent', Math.round(parseFloat(data.hour)));
            $('#easypiechart-blue .percent').text(parseFloat(data.hour)+"%");
            chart1.update(Math.round(parseFloat(data.hour)));
            $("#easypiechart-orange").attr('data-percent', Math.round(parseFloat(data.day)));
            $('#easypiechart-orange .percent').text(parseFloat(data.day) + "%");
            chart2.update(Math.round(parseFloat(data.day)));
            // $("#easypiechart-teal").attr('data-percent', Math.round(parseFloat(data.week)));
            // $('#easypiechart-teal .percent').text(parseFloat(data.week) + "%");
            // chart3.update(Math.round(parseFloat(data.week)));
			// $("#easypiechart-red").attr('data-percent', Math.round(parseFloat(data.month)));
            // $('#easypiechart-red .percent').text(parseFloat(data.month) + "%");
            // chart4.update(Math.round(parseFloat(data.month)));
        }
    })
}

$(document).ready(function () {
    document.getElementById("page-wrapper").style.minHeight=String(document.documentElement.clientHeight - 55) + "px";
    document.getElementById("navbar").style.height=String(document.documentElement.clientHeight - 55) + "px";
    handleProfileSkillPie();
    //get_water_data();
    get_warning_record();
})